import React, { useEffect, useState } from 'react'
import './index.scss'
import axios from '../../api/index'
import dayjs from 'dayjs'
import { useNavigate, useParams } from 'react-router-dom'

function Pllb() {
  const [data, setData] = useState([])
  const { id } = useParams()
  const [doctorId, setDoctorId] = useState<number | string>(id || 1)
  const [page, setPage] = useState(1)
  const [count, setCount] = useState(10)
  const navigate = useNavigate()
  useEffect(() => {
    axios.get('/user/inquiry/v1/findDoctorEvaluateList', {
      params: {
        doctorId: doctorId,
        page: page,
        count: count
      }
    }).then(res => {
      console.log(res);
      setData(res.data.result)
    })
  }, [doctorId, page, count])

  return (
    <div className='pllb'>
      <div className='pllb-top'>
        <span><img src="../../../public/26.png" alt="" className='pllb-top-tp' onClick={() => navigate(-1)} /></span>
        <span className='top-lb'>评论列表</span>
      </div>
      <div className='pl-list'>
        <div className='pllb-item'>
          {
            data.map((item, index) => {
              return <div key={index}>
                <span><img src={item.headPic} alt="" width={'50px'} height={'50px'} className='pltx' /></span>
                <span className='plmc'>{item.nickName}</span>
                <span className='plsj'>{dayjs(item.commentTime).format('YYYY-MM-DD')}</span>
                <p className='plnr'>
                  <span >{item.content}</span>
                </p>
              </div>
            })
          }
        </div>

      </div>
    </div>
  )
}

export default Pllb